<?php

declare(strict_types=1);

namespace App\Traits\Model\Payment;



use App\Model\Orders\Order;
use Hyperf\Database\Model\Relations\BelongsTo;

trait Payment
{
    /**
     * 设置支付单号
     * @param $value
     */
    public function setNoAttribute($value)
    {
        if (!$value) {
            $value = $this->getNo();
        }
        $this->attributes['no'] = $value;
    }

    /**
     * 关联订单
     * @return BelongsTo
     */
    public function order():BelongsTo
    {
        return $this->belongsTo(Order::class, 'order_no', 'no');
    }
}
